Starred
A Starred button allows users to easily like, save, or prioritize an item. It often pins the item to the top of a list or collection for quick access.
#Examples
Use default starred variant for users to toggle the starred state of an item, and enable starring on most lists to allow customisation.
Composition:
- Icon only button: the primary interactive element.
- Star Icon: The primary visual element.
- Tooltip (Recommended): A brief text label appearing on hover or focus (e.g., "Marked as favorite").
Interaction:
- Default (Unstarred): An outlined star icon is used to show the item is not starred.
- Hover: A blue round square border and shadow displayed to indicate that is clickable.
- Starred: Typically, a filled star icon is used to indicate the item is starred.
- Disabled: The icon appears in a visually muted state (e.g., grayed out) with no interaction.
const [starred, setStarred] = useState(false);
return (
<Starred
isStarred={starred}
onChange={setStarred}
aria-label="Pin/unpin whatever this item is"
/>
);
Disable the starred button when the user cannot star an item (e.g., due to permissions) or in read-only views.
const [starred, setStarred] = useState(false);
return (
<Starred
isStarred={starred}
onChange={setStarred}
aria-label="Pin/unpin whatever this item is"
disabled
/>
);
#Properties
Property | Description | Defined | Value |
---|---|---|---|
isStarredRequired | boolean If true, the element selected is starred | ||
onChangeRequired | function Executes once starred button has changed | ||
aria-labelOptional | string Describe what happens if the button is clicked | ||
disabledOptional | boolean Can the button be clicked | ||
data-observe-keyOptional | string Unique string, used by external script e.g. for event tracking | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) | ||
tabIndexOptional | number Tab index of the outermost HTML element of the component | ||
onKeyDownOptional | function Callback for onKeyDown event | ||
onMouseDownOptional | function Callback for onMouseDown event | ||
onMouseEnterOptional | function Callback for onMouseEnter event | ||
onMouseLeaveOptional | function Callback for onMouseLeave event | ||
onFocusOptional | function Callback for onFocus event | ||
onBlurOptional | function Callback for onBlur event |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications